package io.renren.modules.jxgk.controller;


import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;
import io.renren.modules.jxgk.entity.ClassDiaryEntity;
import io.renren.modules.jxgk.entity.ClassInfo;
import io.renren.modules.jxgk.service.ClassInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("classInfo/")
public class ClassInfoController {
    @Autowired
    ClassInfoService classInfoService;

    @RequestMapping("Select")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
        List<ClassInfo> cse = classInfoService.queryList(query);
        int total = classInfoService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(cse, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }


    @RequestMapping("setAdmin")
    public R setAdmin(@RequestParam Map<String, Object> params){
        classInfoService.setAdmin(params);

        return R.ok();
    }

    @RequestMapping("getMyClass")
    public R getMyClass(@RequestParam Map<String, Object> params){
        //查询列表数据
        List<String> list = classInfoService.getMyClass(params);
        return R.ok().put("list", list);
    }

}
